package com.cn.zpark;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: RequestDemo05
 * @Description:
 * @author: RZS
 * @date: 2022/4/12  20:18
 */
@WebServlet("/req5.do")
public class RequestDemo05 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 设置响应数据类型
        response.setContentType("text/html;charset=utf-8");
        // 获取写出流
        PrintWriter writer = response.getWriter();

        writer.println("<h1>RequestDemo05在处理请求</h1>");

        // 获取请求域数据
        String name = (String) request.getAttribute("name");
        String url = (String) request.getAttribute("url");
        writer.println("<h1>"+name+"</h1>");
        writer.println("<h1>"+url+"</h1>");

        writer.close();

    }
}
